package com.aaa.controller;

import com.aaa.pojo.Student;
import com.aaa.service.StudentService;
import com.aaa.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("stu")
public class StudentController {

    @Autowired
    private StudentService studentService;

    /**
     *  用Aid查询数据
     */
    @GetMapping("getById/{AId}")
    public Result getById(@PathVariable Integer AId){
        return studentService.findAll(AId);
    }

    /**
     *  添加数据
     */
    @PostMapping("insert")
    public Result insert(@RequestBody Student student){
        return studentService.insert(student);
    }

    /**
     *  修改数据
     */
    @PutMapping("update")
    public Result update(@RequestBody Student student){
        return studentService.update(student);
    }

    /**
     *  删除数据
     */
    @DeleteMapping("delete/{Aid}")
    public Result delete(@PathVariable Integer Aid){
        return studentService.delete(Aid);
    }
}
